package ru.bmstu.vks.server.view.dialogs;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Toolkit;
import javax.swing.ImageIcon;

public class FileTransferDialog extends JDialog {

	private static final long serialVersionUID = -8297704781024031805L;
	
	private final JPanel contentPanel = new JPanel();
	private JButton applyTransfer;
	private JButton cancelTransfer;
	private boolean fileTransferAccepted = false;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			FileTransferDialog dialog = new FileTransferDialog();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public FileTransferDialog() {
		setIconImage(Toolkit.getDefaultToolkit().getImage(FileTransferDialog.class.getResource("/data/icon.png")));
		setTitle("\u0417\u0430\u0440\u043E\u0441 \u043D\u0430 \u043F\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0444\u0430\u0439\u043B\u0430");
		setResizable(false);
		setModal(true);
		setBounds(100, 100, 344, 112);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		{
			JLabel lblNewLabel = new JLabel("\u041E\u0442 \u043A\u043B\u0438\u0435\u043D\u0442\u0430 \u043F\u043E\u0441\u0442\u0443\u043F\u0438\u043B \u0437\u0430\u043F\u0440\u043E\u0441 \u043D\u0430 \u043F\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u0444\u0430\u0439\u043B\u0430");
			lblNewLabel.setBounds(43, 16, 285, 26);
			contentPanel.add(lblNewLabel);
		}
		{
			JLabel lblNewLabel_1 = new JLabel("");
			lblNewLabel_1.setIcon(new ImageIcon(FileTransferDialog.class.getResource("/data/help.png")));
			lblNewLabel_1.setBounds(10, 11, 46, 37);
			contentPanel.add(lblNewLabel_1);
		}
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				applyTransfer = new JButton("\u0420\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044C");
				applyTransfer.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						fileTransferAccepted = true;
						FileTransferDialog.this.setVisible(false);
					}
				});
				applyTransfer.setActionCommand("OK");
				buttonPane.add(applyTransfer);
				getRootPane().setDefaultButton(applyTransfer);
			}
			{
				cancelTransfer = new JButton("\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C");
				cancelTransfer.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						fileTransferAccepted = false;
						FileTransferDialog.this.setVisible(false);
					}
				});
				cancelTransfer.setActionCommand("Cancel");
				buttonPane.add(cancelTransfer);
			}
		}
	}
	
	public boolean getTransferAccepted() {
		return fileTransferAccepted;
	}

}
